package com.edu.base.ums.memberShareReward.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.edu.base.ums.memberShareReward.domain.ClsMemberShareReward;
import com.edu.base.ums.memberShareReward.service.IClsMemberShareRewardService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会员分享奖励积分记录Controller
 * 
 * @author zw
 * @date 2022-06-28
 */
@RestController
@RequestMapping("/memberShareReward/memberShareReward")
public class ClsMemberShareRewardController extends BaseController
{
    @Autowired
    private IClsMemberShareRewardService clsMemberShareRewardService;

    /**
     * 查询会员分享奖励积分记录列表
     */
    @PreAuthorize("@ss.hasPermi('memberShareReward:memberShareReward:list')")
    @GetMapping("/list")
    public TableDataInfo list(ClsMemberShareReward clsMemberShareReward)
    {
        startPage();
        List<ClsMemberShareReward> list = clsMemberShareRewardService.selectClsMemberShareRewardList(clsMemberShareReward);
        return getDataTable(list);
    }

    /**
     * 导出会员分享奖励积分记录列表
     */
    @PreAuthorize("@ss.hasPermi('memberShareReward:memberShareReward:export')")
    @Log(title = "会员分享奖励积分记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ClsMemberShareReward clsMemberShareReward)
    {
        List<ClsMemberShareReward> list = clsMemberShareRewardService.selectClsMemberShareRewardList(clsMemberShareReward);
        ExcelUtil<ClsMemberShareReward> util = new ExcelUtil<ClsMemberShareReward>(ClsMemberShareReward.class);
        return util.exportExcel(list, "memberShareReward");
    }

    /**
     * 获取会员分享奖励积分记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('memberShareReward:memberShareReward:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(clsMemberShareRewardService.selectClsMemberShareRewardById(id));
    }

    /**
     * 新增会员分享奖励积分记录
     */
    @PreAuthorize("@ss.hasPermi('memberShareReward:memberShareReward:add')")
    @Log(title = "会员分享奖励积分记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClsMemberShareReward clsMemberShareReward)
    {
        return toAjax(clsMemberShareRewardService.insertClsMemberShareReward(clsMemberShareReward));
    }

    /**
     * 修改会员分享奖励积分记录
     */
    @PreAuthorize("@ss.hasPermi('memberShareReward:memberShareReward:edit')")
    @Log(title = "会员分享奖励积分记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClsMemberShareReward clsMemberShareReward)
    {
        return toAjax(clsMemberShareRewardService.updateClsMemberShareReward(clsMemberShareReward));
    }

    /**
     * 删除会员分享奖励积分记录
     */
    @PreAuthorize("@ss.hasPermi('memberShareReward:memberShareReward:remove')")
    @Log(title = "会员分享奖励积分记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(clsMemberShareRewardService.deleteClsMemberShareRewardByIds(ids));
    }
}
